home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / cp / method.c < prev    next >
C/C++ Source or Header  |  1994-07-13  |  51KB  |  1,949 lines

  1. /* Handle the hair of processing (but not expanding) inline functions.
  2.    Also manage function and variable name overloading.
  3.    Copyright (C) 1987, 1989, 1992, 1993 Free Software Foundation, Inc.
  4.    Contributed by Michael Tiemann (tiemann@cygnus.com)
  5.  
  6.    This file is part of GNU CC.
  7.    
  8. GNU CC is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2, or (at your option)
  11. any later version.
  12.  
  13. GNU CC is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with GNU CC; see the file COPYING.  If not, write to
  20. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22.  
  23. #ifndef PARM_CAN_BE_ARRAY_TYPE
  24. #define PARM_CAN_BE_ARRAY_TYPE 1
  25. #endif
  26.  
  27. /* Handle method declarations.  */
  28. #include <stdio.h>
  29. #include "config.h"
  30. #include "tree.h"
  31. #include "cp-tree.h"
  32. #include "class.h"
  33. #include "obstack.h"
  34. #include <ctype.h>
  35. #include "rtl.h"
  36. #include "expr.h"
  37. #include "output.h"
  38. #include "hard-reg-set.h"
  39. #include "flags.h"
  40.  
  41. /* TREE_LIST of the current inline functions that need to be
  42.    processed.  */
  43. struct pending_inline *pending_inlines;
  44.  
  45. #define obstack_chunk_alloc xmalloc
  46. #define obstack_chunk_free free
  47.  
  48. /* Obstack where we build text strings for overloading, etc.  */
  49. static struct obstack scratch_obstack;
  50. static char *scratch_firstobj;
  51.  
  52. # define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0)
  53. # define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C)))
  54. # define OB_PUTC2(C1,C2)    \
  55.   (obstack_1grow (&scratch_obstack, (C1)), obstack_1grow (&scratch_obstack, (C2)))
  56. # define OB_PUTS(S) (obstack_grow (&scratch_obstack, (S), sizeof (S) - 1))
  57. # define OB_PUTID(ID)  \
  58.   (obstack_grow (&scratch_obstack, IDENTIFIER_POINTER (ID),    \
  59.          IDENTIFIER_LENGTH (ID)))
  60. # define OB_PUTCP(S) (obstack_grow (&scratch_obstack, (S), strlen (S)))
  61. # define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0'))
  62.  
  63. #ifdef NO_AUTO_OVERLOAD
  64. int is_overloaded ();
  65. #endif
  66.  
  67. void
  68. init_method ()
  69. {
  70.   gcc_obstack_init (&scratch_obstack);
  71.   scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0);
  72. }
  73.  
  74. /* This must be large enough to hold any printed integer or floating-point
  75.    value.  */
  76. static char digit_buffer[128];
  77.  
  78. /* Move inline function definitions out of structure so that they
  79.    can be processed normally.  CNAME is the name of the class
  80.    we are working from, METHOD_LIST is the list of method lists
  81.    of the structure.  We delete friend methods here, after
  82.    saving away their inline function definitions (if any).  */
  83.  
  84. void
  85. do_inline_function_hair (type, friend_list)
  86.      tree type, friend_list;
  87. {
  88.   tree method = TYPE_METHODS (type);
  89.  
  90.   if (method && TREE_CODE (method) == TREE_VEC)
  91.     {
  92.       if (TREE_VEC_ELT (method, 0))
  93.     method = TREE_VEC_ELT (method, 0);
  94.       else
  95.     method = TREE_VEC_ELT (method, 1);
  96.     }
  97.  
  98.   while (method)
  99.     {
  100.       /* Do inline member functions.  */
  101.       struct pending_inline *info = DECL_PENDING_INLINE_INFO (method);
  102.       if (info)
  103.     {
  104.       tree args;
  105.  
  106.       my_friendly_assert (info->fndecl == method, 238);
  107.       args = DECL_ARGUMENTS (method);
  108.       while (args)
  109.         {
  110.           DECL_CONTEXT (args) = method;
  111.           args = TREE_CHAIN (args);
  112.         }
  113.  
  114.       /* Allow this decl to be seen in global scope.  Don't do this for
  115.              local class methods, though.  */
  116.       if (! current_function_decl)
  117.         IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (method)) = method;
  118.     }
  119.       method = TREE_CHAIN (method);
  120.     }
  121.   while (friend_list)
  122.     {
  123.       tree fndecl = TREE_VALUE (friend_list);
  124.       struct pending_inline *info = DECL_PENDING_INLINE_INFO (fndecl);
  125.       if (info)
  126.     {
  127.       tree args;
  128.  
  129.       my_friendly_assert (info->fndecl == fndecl, 239);
  130.       args = DECL_ARGUMENTS (fndecl);
  131.       while (args)
  132.         {
  133.           DECL_CONTEXT (args) = fndecl;
  134.           args = TREE_CHAIN (args);
  135.         }
  136.  
  137.       /* Allow this decl to be seen in global scope */
  138.       if (! current_function_decl)
  139.         IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (fndecl)) = fndecl;
  140.     }
  141.  
  142.       friend_list = TREE_CHAIN (friend_list);
  143.     }
  144. }
  145.  
  146. /* Report an argument type mismatch between the best declared function
  147.    we could find and the current argument list that we have.  */
  148. void
  149. report_type_mismatch (cp, parmtypes, name_kind)
  150.      struct candidate *cp;
  151.      tree parmtypes;
  152.      char *name_kind;
  153. {
  154.   int i = cp->u.bad_arg;
  155.   tree ttf, tta;
  156.   char *tmp_firstobj;
  157.  
  158.   switch (i)
  159.     {
  160.     case -4:
  161.       my_friendly_assert (TREE_CODE (cp->function) == TEMPLATE_DECL, 240);
  162.       cp_error ("type unification failed for function template `%#D'",
  163.         cp->function);
  164.       return;
  165.  
  166.     case -3:
  167.       if (TYPE_READONLY (TREE_TYPE (TREE_VALUE (parmtypes))))
  168.     cp_error ("call to const %s `%#D' with non-const object", name_kind,
  169.           cp->function);
  170.       else
  171.     cp_error ("call to non-const %s `%#D' with const object", name_kind,
  172.           cp->function);
  173.       return;
  174.     case -2:
  175.       cp_error ("too few arguments for %s `%#D'", name_kind, cp->function);
  176.       return;
  177.     case -1:
  178.       cp_error ("too many arguments for %s `%#D'", name_kind, cp->function);
  179.       return;
  180.     case 0:
  181.       if (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE)
  182.     {
  183.       /* Happens when we have an ambiguous base class.  */
  184.       my_friendly_assert (get_binfo (DECL_CLASS_CONTEXT (cp->function),
  185.                  TREE_TYPE (TREE_TYPE (TREE_VALUE (parmtypes))), 1) == error_mark_node,
  186.                   241);
  187.       return;
  188.     }
  189.     }
  190.  
  191.   ttf = TYPE_ARG_TYPES (TREE_TYPE (cp->function));
  192.   tta = parmtypes;
  193.  
  194.   while (i-- > 0)
  195.     {
  196.       ttf = TREE_CHAIN (ttf);
  197.       tta = TREE_CHAIN (tta);
  198.     }
  199.  
  200.   OB_INIT ();
  201.   OB_PUTS ("bad argument ");
  202.   sprintf (digit_buffer, "%d", cp->u.bad_arg
  203.        - (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE)
  204.        + 1);
  205.   OB_PUTCP (digit_buffer);
  206.  
  207.   OB_PUTS (" for function `");
  208.   OB_PUTCP (decl_as_string (cp->function, 1));
  209.   OB_PUTS ("' (type was ");
  210.  
  211.   /* Reset `i' so that type printing routines do the right thing.  */
  212.   if (tta)
  213.     {
  214.       enum tree_code code = TREE_CODE (TREE_TYPE (TREE_VALUE (tta)));
  215.       if (code == ERROR_MARK)
  216.     OB_PUTS ("(failed type instantiation)");
  217.       else
  218.     {
  219.       i = (code == FUNCTION_TYPE || code == METHOD_TYPE);
  220.       OB_PUTCP (type_as_string (TREE_TYPE (TREE_VALUE (tta)), 1));
  221.     }
  222.     }
  223.   else OB_PUTS ("void");
  224.   OB_PUTC (')');
  225.   OB_FINISH ();
  226.  
  227.   tmp_firstobj = (char *)alloca (obstack_object_size (&scratch_obstack));
  228.   bcopy (obstack_base (&scratch_obstack), tmp_firstobj,
  229.      obstack_object_size (&scratch_obstack));
  230.   error (tmp_firstobj);
  231. }
  232.  
  233. /* Here is where overload code starts.  */
  234.  
  235. /* Array of types seen so far in top-level call to `build_overload_name'.
  236.    Allocated and deallocated by caller.  */
  237. static tree *typevec;
  238.  
  239. /* Number of types interned by `build_overload_name' so far.  */
  240. static int maxtype;
  241.  
  242. /* Number of occurrences of last type seen.  */
  243. static int nrepeats;
  244.  
  245. /* Nonzero if we should not try folding parameter types.  */
  246. static int nofold;
  247.  
  248. #define ALLOCATE_TYPEVEC(PARMTYPES) \
  249.   do { maxtype = 0, nrepeats = 0; \
  250.        typevec = (tree *)alloca (list_length (PARMTYPES) * sizeof (tree)); } while (0)
  251.  
  252. #define DEALLOCATE_TYPEVEC(PARMTYPES) \
  253.   do { tree t = (PARMTYPES); \
  254.        while (t) { TREE_USED (TREE_VALUE (t)) = 0; t = TREE_CHAIN (t); } \
  255.   } while (0)
  256.  
  257. /* Code to concatenate an asciified integer to a string.  */
  258. static
  259. #ifdef __GNUC__
  260. __inline
  261. #endif
  262. void
  263. icat (i)
  264.      int i;
  265. {
  266.   /* Handle this case first, to go really quickly.  For many common values,
  267.      the result of i/10 below is 1.  */
  268.   if (i == 1)
  269.     {
  270.       OB_PUTC ('1');
  271.       return;
  272.     }
  273.  
  274.   if (i < 0)
  275.     {
  276.       OB_PUTC ('m');
  277.       i = -i;
  278.     }
  279.   if (i < 10)
  280.     OB_PUTC ('0' + i);
  281.   else
  282.     {
  283.       icat (i / 10);
  284.       OB_PUTC ('0' + (i % 10));
  285.     }
  286. }
  287.  
  288. static
  289. #ifdef __GNUC__
  290. __inline
  291. #endif
  292. void
  293. flush_repeats (type)
  294.      tree type;
  295. {
  296.   int tindex = 0;
  297.  
  298.   while (typevec[tindex] != type)
  299.     tindex++;
  300.  
  301.   if (nrepeats > 1)
  302.     {
  303.       OB_PUTC ('N');
  304.       icat (nrepeats);
  305.       if (nrepeats > 9)
  306.     OB_PUTC ('_');
  307.     }
  308.   else
  309.     OB_PUTC ('T');
  310.   nrepeats = 0;
  311.   icat (tindex);
  312.   if (tindex > 9)
  313.     OB_PUTC ('_');
  314. }
  315.  
  316. static void build_overload_identifier ();
  317.  
  318. static void
  319. build_overload_nested_name (context)
  320.      tree context;
  321. {
  322.   /* We use DECL_NAME here, because pushtag now sets the DECL_ASSEMBLER_NAME.  */
  323.   tree name = DECL_NAME (context);
  324.   if (DECL_CONTEXT (context))
  325.     {
  326.       context = DECL_CONTEXT (context);
  327.       if (TREE_CODE_CLASS (TREE_CODE (context)) == 't')
  328.     context = TYPE_NAME (context);
  329.       build_overload_nested_name (context);
  330.     }
  331.   build_overload_identifier (name);
  332. }
  333.  
  334. static void
  335. build_overload_value (type, value)
  336.      tree type, value;
  337. {
  338.   while (TREE_CODE (value) == NON_LVALUE_EXPR
  339.      || TREE_CODE (value) == NOP_EXPR)
  340.     value = TREE_OPERAND (value, 0);
  341.   my_friendly_assert (TREE_CODE (type) == PARM_DECL, 242);
  342.   type = TREE_TYPE (type);
  343.   switch (TREE_CODE (type))
  344.     {
  345.     case INTEGER_TYPE:
  346.     case ENUMERAL_TYPE:
  347.       {
  348.     my_friendly_assert (TREE_CODE (value) == INTEGER_CST, 243);
  349.     if (TYPE_PRECISION (value) == 2 * HOST_BITS_PER_WIDE_INT)
  350.       {
  351.         if (tree_int_cst_lt (value, integer_zero_node))
  352.           {
  353.         OB_PUTC ('m');
  354.         value = build_int_2 (~ TREE_INT_CST_LOW (value),
  355.                      - TREE_INT_CST_HIGH (value));
  356.           }
  357.         if (TREE_INT_CST_HIGH (value)
  358.         != (TREE_INT_CST_LOW (value) >> (HOST_BITS_PER_WIDE_INT - 1)))
  359.           {
  360.         /* need to print a DImode value in decimal */
  361.         sorry ("conversion of long long as PT parameter");
  362.           }
  363.         /* else fall through to print in smaller mode */
  364.       }
  365.     /* Wordsize or smaller */
  366.     icat (TREE_INT_CST_LOW (value));
  367.     return;
  368.       }
  369.     case BOOLEAN_TYPE:
  370.       {
  371.     icat (TREE_INT_CST_LOW (value));
  372.     return;
  373.       }
  374. #ifndef REAL_IS_NOT_DOUBLE
  375.     case REAL_TYPE:
  376.       {
  377.     REAL_VALUE_TYPE val;
  378.     char *bufp = digit_buffer;
  379.     extern char *index ();
  380.  
  381.     my_friendly_assert (TREE_CODE (value) == REAL_CST, 244);
  382.     val = TREE_REAL_CST (value);
  383.     if (val < 0)
  384.       {
  385.         val = -val;
  386.         *bufp++ = 'm';
  387.       }
  388.     sprintf (bufp, "%e", val);
  389.     bufp = (char *) index (bufp, 'e');
  390.     if (!bufp)
  391.       strcat (digit_buffer, "e0");
  392.     else
  393.       {
  394.         char *p;
  395.         bufp++;
  396.         if (*bufp == '-')
  397.           {
  398.         *bufp++ = 'm';
  399.           }
  400.         p = bufp;
  401.         if (*p == '+')
  402.           p++;
  403.         while (*p == '0')
  404.           p++;
  405.         if (*p == 0)
  406.           {
  407.         *bufp++ = '0';
  408.         *bufp = 0;
  409.           }
  410.         else if (p != bufp)
  411.           {
  412.         while (*p)
  413.           *bufp++ = *p++;
  414.         *bufp = 0;
  415.           }
  416.       }
  417.     OB_PUTCP (digit_buffer);
  418.     return;
  419.       }
  420. #endif
  421.     case POINTER_TYPE:
  422.       value = TREE_OPERAND (value, 0);
  423.       if (TREE_CODE (value) == VAR_DECL)
  424.     {
  425.       my_friendly_assert (DECL_NAME (value) != 0, 245);
  426.       build_overload_identifier (DECL_NAME (value));
  427.       return;
  428.     }
  429.       else if (TREE_CODE (value) == FUNCTION_DECL)
  430.     {
  431.       my_friendly_assert (DECL_NAME (value) != 0, 246);
  432.       build_overload_identifier (DECL_NAME (value));
  433.       return;
  434.     }
  435.       else
  436.     my_friendly_abort (71);
  437.       break; /* not really needed */
  438.  
  439.     default:
  440.       sorry ("conversion of %s as template parameter",
  441.          tree_code_name [(int) TREE_CODE (type)]);
  442.       my_friendly_abort (72);
  443.     }
  444. }
  445.  
  446. static void
  447. build_overload_identifier (name)
  448.      tree name;
  449. {
  450.   if (IDENTIFIER_TEMPLATE (name))
  451.     {
  452.       tree template, parmlist, arglist, tname;
  453.       int i, nparms;
  454.       template = IDENTIFIER_TEMPLATE (name);
  455.       arglist = TREE_VALUE (template);
  456.       template = TREE_PURPOSE (template);
  457.       tname = DECL_NAME (template);
  458.       parmlist = DECL_ARGUMENTS (template);
  459.       nparms = TREE_VEC_LENGTH (parmlist);
  460.       OB_PUTC ('t');
  461.       icat (IDENTIFIER_LENGTH (tname));
  462.       OB_PUTID (tname);
  463.       icat (nparms);
  464.       for (i = 0; i < nparms; i++)
  465.     {
  466.       tree parm = TREE_VEC_ELT (parmlist, i);
  467.       tree arg = TREE_VEC_ELT (arglist, i);
  468.       if (TREE_CODE (parm) == IDENTIFIER_NODE)
  469.         {
  470.           /* This parameter is a type.  */
  471.           OB_PUTC ('Z');
  472.           build_overload_name (arg, 0, 0);
  473.         }
  474.       else
  475.         {
  476.           /* It's a PARM_DECL.  */
  477.           build_overload_name (TREE_TYPE (parm), 0, 0);
  478.           build_overload_value (parm, arg);
  479.         }
  480.     }
  481.     }
  482.   else
  483.     {
  484.       icat (IDENTIFIER_LENGTH (name));
  485.       OB_PUTID (name);
  486.     }
  487. }
  488.  
  489. /* Given a list of parameters in PARMTYPES, create an unambiguous
  490.    overload string. Should distinguish any type that C (or C++) can
  491.    distinguish. I.e., pointers to functions are treated correctly.
  492.  
  493.    Caller must deal with whether a final `e' goes on the end or not.
  494.  
  495.    Any default conversions must take place before this function
  496.    is called.
  497.  
  498.    BEGIN and END control initialization and finalization of the
  499.    obstack where we build the string.  */
  500.  
  501. char *
  502. build_overload_name (parmtypes, begin, end)
  503.      tree parmtypes;
  504.      int begin, end;
  505. {
  506.   int just_one;
  507.   tree parmtype;
  508.  
  509.   if (begin) OB_INIT ();
  510.  
  511.   if ((just_one = (TREE_CODE (parmtypes) != TREE_LIST)))
  512.     {
  513.       parmtype = parmtypes;
  514.       goto only_one;
  515.     }
  516.  
  517.   while (parmtypes)
  518.     {
  519.       parmtype = TREE_VALUE (parmtypes);
  520.  
  521.     only_one:
  522.  
  523.       if (! nofold)
  524.     {
  525.       if (! just_one)
  526.         /* Every argument gets counted.  */
  527.         typevec[maxtype++] = parmtype;
  528.  
  529.       if (TREE_USED (parmtype))
  530.         {
  531.           if (! just_one && parmtype == typevec[maxtype-2])
  532.         nrepeats++;
  533.           else
  534.         {
  535.           if (nrepeats)
  536.             flush_repeats (parmtype);
  537.           if (! just_one && TREE_CHAIN (parmtypes)
  538.               && parmtype == TREE_VALUE (TREE_CHAIN (parmtypes)))
  539.             nrepeats++;
  540.           else
  541.             {
  542.               int tindex = 0;
  543.  
  544.               while (typevec[tindex] != parmtype)
  545.             tindex++;
  546.               OB_PUTC ('T');
  547.               icat (tindex);
  548.               if (tindex > 9)
  549.             OB_PUTC ('_');
  550.             }
  551.         }
  552.           goto next;
  553.         }
  554.       if (nrepeats)
  555.         flush_repeats (typevec[maxtype-2]);
  556.       if (! just_one
  557.           /* Only cache types which take more than one character.  */
  558.           && (parmtype != TYPE_MAIN_VARIANT (parmtype)
  559.           || (TREE_CODE (parmtype) != INTEGER_TYPE
  560.               && TREE_CODE (parmtype) != REAL_TYPE)))
  561.         TREE_USED (parmtype) = 1;
  562.     }
  563.  
  564.       if (TYPE_PTRMEMFUNC_P (parmtype))
  565.     parmtype = TYPE_PTRMEMFUNC_FN_TYPE (parmtype);
  566.  
  567.       if (TREE_READONLY (parmtype))
  568.     OB_PUTC ('C');
  569.       if (TREE_CODE (parmtype) == INTEGER_TYPE
  570.       && TYPE_MAIN_VARIANT (parmtype) == unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
  571.     OB_PUTC ('U');
  572.       if (TYPE_VOLATILE (parmtype))
  573.     OB_PUTC ('V');
  574.  
  575.       switch (TREE_CODE (parmtype))
  576.     {
  577.     case OFFSET_TYPE:
  578.       OB_PUTC ('O');
  579.       build_overload_name (TYPE_OFFSET_BASETYPE (parmtype), 0, 0);
  580.       OB_PUTC ('_');
  581.       build_overload_name (TREE_TYPE (parmtype), 0, 0);
  582.       break;
  583.  
  584.     case REFERENCE_TYPE:
  585.       OB_PUTC ('R');
  586.       goto more;
  587.  
  588.     case ARRAY_TYPE:
  589. #if PARM_CAN_BE_ARRAY_TYPE
  590.       {
  591.         tree length;
  592.  
  593.         OB_PUTC ('A');
  594.         if (TYPE_DOMAIN (parmtype) == NULL_TREE)
  595.           error ("pointer or reference to array of unknown bound in parm type");
  596.         else
  597.           {
  598.         length = array_type_nelts (parmtype);
  599.         if (TREE_CODE (length) == INTEGER_CST)
  600.           icat (TREE_INT_CST_LOW (length) + 1);
  601.           }
  602.         OB_PUTC ('_');
  603.         goto more;
  604.       }
  605. #else
  606.       OB_PUTC ('P');
  607.       goto more;
  608. #endif
  609.  
  610.     case POINTER_TYPE:
  611.       OB_PUTC ('P');
  612.     more:
  613.       build_overload_name (TREE_TYPE (parmtype), 0, 0);
  614.       break;
  615.  
  616.     case FUNCTION_TYPE:
  617.     case METHOD_TYPE:
  618.       {
  619.         tree firstarg = TYPE_ARG_TYPES (parmtype);
  620.         /* Otherwise have to implement reentrant typevecs,
  621.            unmark and remark types, etc.  */
  622.         int old_nofold = nofold;
  623.         nofold = 1;
  624.  
  625.         if (nrepeats)
  626.           flush_repeats (typevec[maxtype-1]);
  627.  
  628.         /* @@ It may be possible to pass a function type in
  629.            which is not preceded by a 'P'.  */
  630.         if (TREE_CODE (parmtype) == FUNCTION_TYPE)
  631.           {
  632.         OB_PUTC ('F');
  633.         if (firstarg == NULL_TREE)
  634.           OB_PUTC ('e');
  635.         else if (firstarg == void_list_node)
  636.           OB_PUTC ('v');
  637.         else
  638.           build_overload_name (firstarg, 0, 0);
  639.           }
  640.         else
  641.           {
  642.         int constp = TYPE_READONLY (TREE_TYPE (TREE_VALUE (firstarg)));
  643.         int volatilep = TYPE_VOLATILE (TREE_TYPE (TREE_VALUE (firstarg)));
  644.         OB_PUTC ('M');
  645.         firstarg = TREE_CHAIN (firstarg);
  646.  
  647.         build_overload_name (TYPE_METHOD_BASETYPE (parmtype), 0, 0);
  648.         if (constp)
  649.           OB_PUTC ('C');
  650.         if (volatilep)
  651.           OB_PUTC ('V');
  652.  
  653.         /* For cfront 2.0 compatibility.  */
  654.         OB_PUTC ('F');
  655.  
  656.         if (firstarg == NULL_TREE)
  657.           OB_PUTC ('e');
  658.         else if (firstarg == void_list_node)
  659.           OB_PUTC ('v');
  660.         else
  661.           build_overload_name (firstarg, 0, 0);
  662.           }
  663.  
  664.         /* Separate args from return type.  */
  665.         OB_PUTC ('_');
  666.         build_overload_name (TREE_TYPE (parmtype), 0, 0);
  667.         nofold = old_nofold;
  668.         break;
  669.       }
  670.  
  671.     case INTEGER_TYPE:
  672.       parmtype = TYPE_MAIN_VARIANT (parmtype);
  673.       if (parmtype == integer_type_node
  674.           || parmtype == unsigned_type_node)
  675.         OB_PUTC ('i');
  676.       else if (parmtype == long_integer_type_node
  677.            || parmtype == long_unsigned_type_node)
  678.         OB_PUTC ('l');
  679.       else if (parmtype == short_integer_type_node
  680.            || parmtype == short_unsigned_type_node)
  681.         OB_PUTC ('s');
  682.       else if (parmtype == signed_char_type_node)
  683.         {
  684.           OB_PUTC ('S');
  685.           OB_PUTC ('c');
  686.         }
  687.       else if (parmtype == char_type_node
  688.            || parmtype == unsigned_char_type_node)
  689.         OB_PUTC ('c');
  690.       else if (parmtype == wchar_type_node)
  691.         OB_PUTC ('w');
  692.       else if (parmtype == long_long_integer_type_node
  693.           || parmtype == long_long_unsigned_type_node)
  694.         OB_PUTC ('x');
  695. #if 0
  696.       /* it would seem there is no way to enter these in source code,
  697.          yet.  (mrs) */
  698.       else if (parmtype == long_long_long_integer_type_node
  699.           || parmtype == long_long_long_unsigned_type_node)
  700.         OB_PUTC ('q');
  701. #endif
  702.       else
  703.         my_friendly_abort (73);
  704.       break;
  705.  
  706.     case BOOLEAN_TYPE:
  707.       OB_PUTC ('b');
  708.       break;
  709.  
  710.     case REAL_TYPE:
  711.       parmtype = TYPE_MAIN_VARIANT (parmtype);
  712.       if (parmtype == long_double_type_node)
  713.         OB_PUTC ('r');
  714.       else if (parmtype == double_type_node)
  715.         OB_PUTC ('d');
  716.       else if (parmtype == float_type_node)
  717.         OB_PUTC ('f');
  718.       else my_friendly_abort (74);
  719.       break;
  720.  
  721.     case VOID_TYPE:
  722.       if (! just_one)
  723.         {
  724. #if 0
  725.           extern tree void_list_node;
  726.  
  727.           /* See if anybody is wasting memory.  */
  728.           my_friendly_assert (parmtypes == void_list_node, 247);
  729. #endif
  730.           /* This is the end of a parameter list.  */
  731.           if (end) OB_FINISH ();
  732.           return (char *)obstack_base (&scratch_obstack);
  733.         }
  734.       OB_PUTC ('v');
  735.       break;
  736.  
  737.     case ERROR_MARK:    /* not right, but nothing is anyway */
  738.       break;
  739.  
  740.       /* have to do these */
  741.     case UNION_TYPE:
  742.     case RECORD_TYPE:
  743.       if (! just_one)
  744.         /* Make this type signature look incompatible
  745.            with AT&T.  */
  746.         OB_PUTC ('G');
  747.       goto common;
  748.     case ENUMERAL_TYPE:
  749.     common:
  750.       {
  751.         tree name = TYPE_NAME (parmtype);
  752.         int i = 1;
  753.  
  754.         if (TREE_CODE (name) == TYPE_DECL)
  755.           {
  756.         tree context = name;
  757.         while (DECL_CONTEXT (context))
  758.           {
  759.             i += 1;
  760.             context = DECL_CONTEXT (context);
  761.             if (TREE_CODE_CLASS (TREE_CODE (context)) == 't')
  762.               context = TYPE_NAME (context);
  763.           }
  764.         name = DECL_NAME (name);
  765.           }
  766.         my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 248);
  767.         if (i > 1)
  768.           {
  769.         OB_PUTC ('Q');
  770.         if (i > 9)
  771.           OB_PUTC ('_');
  772.         icat (i);
  773.         if (i > 9)
  774.           OB_PUTC ('_');
  775.         build_overload_nested_name (TYPE_NAME (parmtype));
  776.           }
  777.         else
  778.           build_overload_identifier (name);
  779.         break;
  780.       }
  781.  
  782.     case UNKNOWN_TYPE:
  783.       /* This will take some work.  */
  784.       OB_PUTC ('?');
  785.       break;
  786.  
  787.     case TEMPLATE_TYPE_PARM:
  788.     case TEMPLATE_CONST_PARM:
  789.         case UNINSTANTIATED_P_TYPE:
  790.       /* We don't ever want this output, but it's inconvenient not to
  791.          be able to build the string.  This should cause assembler
  792.          errors we'll notice.  */
  793.       {
  794.         static int n;
  795.         sprintf (digit_buffer, " *%d", n++);
  796.         OB_PUTCP (digit_buffer);
  797.       }
  798.       break;
  799.  
  800.     default:
  801.       my_friendly_abort (75);
  802.     }
  803.  
  804.     next:
  805.       if (just_one) break;
  806.       parmtypes = TREE_CHAIN (parmtypes);
  807.     }
  808.   if (! just_one)
  809.     {
  810.       if (nrepeats)
  811.     flush_repeats (typevec[maxtype-1]);
  812.  
  813.       /* To get here, parms must end with `...'. */
  814.       OB_PUTC ('e');
  815.     }
  816.  
  817.   if (end) OB_FINISH ();
  818.   return (char *)obstack_base (&scratch_obstack);
  819. }
  820.  
  821. /* Generate an identifier that encodes the (ANSI) exception TYPE. */
  822.  
  823. /* This should be part of `ansi_opname', or at least be defined by the std.  */
  824. #define EXCEPTION_NAME_PREFIX "__ex"
  825. #define EXCEPTION_NAME_LENGTH 4
  826.  
  827. tree
  828. cplus_exception_name (type)
  829.      tree type;
  830. {
  831.   OB_INIT ();
  832.   OB_PUTS (EXCEPTION_NAME_PREFIX);
  833.   return get_identifier (build_overload_name (type, 0, 1));
  834. }
  835.  
  836. /* Change the name of a function definition so that it may be
  837.    overloaded. NAME is the name of the function to overload,
  838.    PARMS is the parameter list (which determines what name the
  839.    final function obtains).
  840.  
  841.    FOR_METHOD is 1 if this overload is being performed
  842.    for a method, rather than a function type.  It is 2 if
  843.    this overload is being performed for a constructor.  */
  844. tree
  845. build_decl_overload (dname, parms, for_method)
  846.      tree dname;
  847.      tree parms;
  848.      int for_method;
  849. {
  850.   char *name = IDENTIFIER_POINTER (dname);
  851.  
  852.   /* member operators new and delete look like methods at this point.  */
  853.   if (! for_method && parms != NULL_TREE && TREE_CODE (parms) == TREE_LIST)
  854.     {
  855.       if (TREE_VALUE (parms) == sizetype
  856.       && TREE_CHAIN (parms) == void_list_node)
  857.     {
  858.       if (dname == ansi_opname[(int) NEW_EXPR])
  859.         return get_identifier ("__builtin_new");
  860.       else if (dname == ansi_opname[(int) VEC_NEW_EXPR])
  861.         return get_identifier ("__builtin_vec_new");
  862.     }
  863.       else if (dname == ansi_opname[(int) DELETE_EXPR])
  864.     return get_identifier ("__builtin_delete");
  865.       else if (dname == ansi_opname[(int) VEC_DELETE_EXPR])
  866.     return get_identifier ("__builtin_vec_delete");
  867.     }
  868.  
  869.   OB_INIT ();
  870.   if (for_method != 2)
  871.     OB_PUTCP (name);
  872.   /* Otherwise, we can divine that this is a constructor,
  873.      and figure out its name without any extra encoding.  */
  874.  
  875.   OB_PUTC2 ('_', '_');
  876.   if (for_method)
  877.     {
  878. #if 0
  879.       /* We can get away without doing this.  */
  880.       OB_PUTC ('M');
  881. #endif
  882.       {
  883.     tree this_type = TREE_VALUE (parms);
  884.  
  885.     if (TREE_CODE (this_type) == RECORD_TYPE)  /* a signature pointer */
  886.       parms = temp_tree_cons (NULL_TREE, SIGNATURE_TYPE (this_type),
  887.                   TREE_CHAIN (parms));
  888.     else
  889.       parms = temp_tree_cons (NULL_TREE, TREE_TYPE (this_type),
  890.                   TREE_CHAIN (parms));
  891.       }
  892.     }
  893.   else
  894.     OB_PUTC ('F');
  895.  
  896.   if (parms == NULL_TREE)
  897.     OB_PUTC2 ('e', '\0');
  898.   else if (parms == void_list_node)
  899.     OB_PUTC2 ('v', '\0');
  900.   else
  901.     {
  902.       ALLOCATE_TYPEVEC (parms);
  903.       nofold = 0;
  904.       if (for_method)
  905.     {
  906.       build_overload_name (TREE_VALUE (parms), 0, 0);
  907.  
  908.       typevec[maxtype++] = TREE_VALUE (parms);
  909.       TREE_USED (TREE_VALUE (parms)) = 1;
  910.  
  911.       if (TREE_CHAIN (parms))
  912.         build_overload_name (TREE_CHAIN (parms), 0, 1);
  913.       else
  914.         OB_PUTC2 ('e', '\0');
  915.     }
  916.       else
  917.     build_overload_name (parms, 0, 1);
  918.       DEALLOCATE_TYPEVEC (parms);
  919.     }
  920.   {
  921.     tree n = get_identifier (obstack_base (&scratch_obstack));
  922.     if (IDENTIFIER_OPNAME_P (dname))
  923.       IDENTIFIER_OPNAME_P (n) = 1;
  924.     return n;
  925.   }
  926. }
  927.  
  928. /* Build an overload name for the type expression TYPE.  */
  929. tree
  930. build_typename_overload (type)
  931.      tree type;
  932. {
  933.   tree id;
  934.  
  935.   OB_INIT ();
  936.   OB_PUTID (ansi_opname[(int) TYPE_EXPR]);
  937.   nofold = 1;
  938.   build_overload_name (type, 0, 1);
  939.   id = get_identifier (obstack_base (&scratch_obstack));
  940.   IDENTIFIER_OPNAME_P (id) = 1;
  941. #if 0
  942.   IDENTIFIER_GLOBAL_VALUE (id) = TYPE_NAME (type);
  943. #endif
  944.   TREE_TYPE (id) = type;
  945.   return id;
  946. }
  947.  
  948. #ifndef NO_DOLLAR_IN_LABEL
  949. #define T_DESC_FORMAT "TD$"
  950. #define I_DESC_FORMAT "ID$"
  951. #define M_DESC_FORMAT "MD$"
  952. #else
  953. #if !defined(NO_DOT_IN_LABEL)
  954. #define T_DESC_FORMAT "TD."
  955. #define I_DESC_FORMAT "ID."
  956. #define M_DESC_FORMAT "MD."
  957. #else
  958. #define T_DESC_FORMAT "__t_desc_"
  959. #define I_DESC_FORMAT "__i_desc_"
  960. #define M_DESC_FORMAT "__m_desc_"
  961. #endif
  962. #endif
  963.  
  964. /* Build an overload name for the type expression TYPE.  */
  965. tree
  966. build_t_desc_overload (type)
  967.      tree type;
  968. {
  969.   OB_INIT ();
  970.   OB_PUTS (T_DESC_FORMAT);
  971.   nofold = 1;
  972.  
  973. #if 0
  974.   /* Use a different format if the type isn't defined yet.  */
  975.   if (TYPE_SIZE (type) == NULL_TREE)
  976.     {
  977.       char *p;
  978.       int changed;
  979.  
  980.       for (p = tname; *p; p++)
  981.     if (isupper (*p))
  982.       {
  983.         changed = 1;
  984.         *p = tolower (*p);
  985.       }
  986.       /* If there's no change, we have an inappropriate T_DESC_FORMAT.  */
  987.       my_friendly_assert (changed != 0, 249);
  988.     }
  989. #endif
  990.  
  991.   build_overload_name (type, 0, 1);
  992.   return get_identifier (obstack_base (&scratch_obstack));
  993. }
  994.  
  995. /* Top-level interface to explicit overload requests. Allow NAME
  996.    to be overloaded. Error if NAME is already declared for the current
  997.    scope. Warning if function is redundantly overloaded. */
  998.  
  999. void
  1000. declare_overloaded (name)
  1001.      tree name;
  1002. {
  1003. #ifdef NO_AUTO_OVERLOAD
  1004.   if (is_overloaded (name))
  1005.     warning ("function `%s' already declared overloaded",
  1006.          IDENTIFIER_POINTER (name));
  1007.   else if (IDENTIFIER_GLOBAL_VALUE (name))
  1008.     error ("overloading function `%s' that is already defined",
  1009.        IDENTIFIER_POINTER (name));
  1010.   else
  1011.     {
  1012.       TREE_OVERLOADED (name) = 1;
  1013.       IDENTIFIER_GLOBAL_VALUE (name) = build_tree_list (name, NULL_TREE);
  1014.       TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name)) = unknown_type_node;
  1015.     }
  1016. #else
  1017.   if (current_lang_name == lang_name_cplusplus)
  1018.     {
  1019.       if (0)
  1020.     warning ("functions are implicitly overloaded in C++");
  1021.     }
  1022.   else if (current_lang_name == lang_name_c)
  1023.     error ("overloading function `%s' cannot be done in C language context");
  1024.   else
  1025.     my_friendly_abort (76);
  1026. #endif
  1027. }
  1028.  
  1029. #ifdef NO_AUTO_OVERLOAD
  1030. /* Check to see if NAME is overloaded. For first approximation,
  1031.    check to see if its TREE_OVERLOADED is set.  This is used on
  1032.    IDENTIFIER nodes.  */
  1033. int
  1034. is_overloaded (name)
  1035.      tree name;
  1036. {
  1037.   /* @@ */
  1038.   return (TREE_OVERLOADED (name)
  1039.       && (! IDENTIFIER_CLASS_VALUE (name) || current_class_type == 0)
  1040.       && ! IDENTIFIER_LOCAL_VALUE (name));
  1041. }
  1042. #endif
  1043.  
  1044. /* Given a tree_code CODE, and some arguments (at least one),
  1045.    attempt to use an overloaded operator on the arguments.
  1046.  
  1047.    For unary operators, only the first argument need be checked.
  1048.    For binary operators, both arguments may need to be checked.
  1049.  
  1050.    Member functions can convert class references to class pointers,
  1051.    for one-level deep indirection.  More than that is not supported.
  1052.    Operators [](), ()(), and ->() must be member functions.
  1053.  
  1054.    We call function call building calls with LOOKUP_COMPLAIN if they
  1055.    are our only hope.  This is true when we see a vanilla operator
  1056.    applied to something of aggregate type.  If this fails, we are free
  1057.    to return `error_mark_node', because we will have reported the
  1058.    error.
  1059.  
  1060.    Operators NEW and DELETE overload in funny ways: operator new takes
  1061.    a single `size' parameter, and operator delete takes a pointer to the
  1062.    storage being deleted.  When overloading these operators, success is
  1063.    assumed.  If there is a failure, report an error message and return
  1064.    `error_mark_node'.  */
  1065.  
  1066. /* NOSTRICT */
  1067. tree
  1068. build_opfncall (code, flags, xarg1, xarg2, arg3)
  1069.      enum tree_code code;
  1070.      int flags;
  1071.      tree xarg1, xarg2, arg3;
  1072. {
  1073.   tree rval = 0;
  1074.   tree arg1, arg2;
  1075.   tree type1, type2, fnname;
  1076.   tree fields1 = 0, parms = 0;
  1077.   tree global_fn;
  1078.   int try_second;
  1079.   int binary_is_unary;
  1080.  
  1081.   if (xarg1 == error_mark_node)
  1082.     return error_mark_node;
  1083.  
  1084.   if (code == COND_EXPR)
  1085.     {
  1086.       if (TREE_CODE (xarg2) == ERROR_MARK
  1087.       || TREE_CODE (arg3) == ERROR_MARK)
  1088.     return error_mark_node;
  1089.     }
  1090.   if (code == COMPONENT_REF)
  1091.     if (TREE_CODE (TREE_TYPE (xarg1)) == POINTER_TYPE)
  1092.       return rval;
  1093.  
  1094.   /* First, see if we can work with the first argument */
  1095.   type1 = TREE_TYPE (xarg1);
  1096.  
  1097.   /* Some tree codes have length > 1, but we really only want to
  1098.      overload them if their first argument has a user defined type.  */
  1099.   switch (code)
  1100.     {
  1101.     case PREINCREMENT_EXPR:
  1102.     case PREDECREMENT_EXPR:
  1103.     case POSTINCREMENT_EXPR:
  1104.     case POSTDECREMENT_EXPR:
  1105.     case COMPONENT_REF:
  1106.       binary_is_unary = 1;
  1107.       try_second = 0;
  1108.       break;
  1109.  
  1110.       /* ARRAY_REFs and CALL_EXPRs must overload successfully.
  1111.      If they do not, return error_mark_node instead of NULL_TREE.  */
  1112.     case ARRAY_REF:
  1113.       if (xarg2 == error_mark_node)
  1114.     return error_mark_node;
  1115.     case CALL_EXPR:
  1116.       rval = error_mark_node;
  1117.       binary_is_unary = 0;
  1118.       try_second = 0;
  1119.       break;
  1120.  
  1121.     case VEC_NEW_EXPR:
  1122.     case NEW_EXPR:
  1123.       {
  1124.     tree args = tree_cons (NULL_TREE, xarg2, arg3);
  1125.     fnname = ansi_opname[(int) code];
  1126.     if (flags & LOOKUP_GLOBAL)
  1127.       return build_overload_call (fnname, args, flags & LOOKUP_COMPLAIN,
  1128.                       (struct candidate *)0);
  1129.  
  1130.     rval = build_method_call
  1131.       (build_indirect_ref (build1 (NOP_EXPR, xarg1, error_mark_node),
  1132.                    "new"),
  1133.        fnname, args, NULL_TREE, flags);
  1134.     if (rval == error_mark_node)
  1135.       /* User might declare fancy operator new, but invoke it
  1136.          like standard one.  */
  1137.       return rval;
  1138.  
  1139.     TREE_TYPE (rval) = xarg1;
  1140.     TREE_CALLS_NEW (rval) = 1;
  1141.     return rval;
  1142.       }
  1143.       break;
  1144.  
  1145.     case VEC_DELETE_EXPR:
  1146.     case DELETE_EXPR:
  1147.       {
  1148.     fnname = ansi_opname[(int) code];
  1149.     if (flags & LOOKUP_GLOBAL)
  1150.       return build_overload_call (fnname,
  1151.                       build_tree_list (NULL_TREE, xarg1),
  1152.                       flags & LOOKUP_COMPLAIN,
  1153.                       (struct candidate *)0);
  1154.  
  1155.     rval = build_method_call
  1156.       (build_indirect_ref (build1 (NOP_EXPR, TREE_TYPE (xarg1),
  1157.                        error_mark_node),
  1158.                    NULL_PTR),
  1159.        fnname, tree_cons (NULL_TREE, xarg1,
  1160.                    build_tree_list (NULL_TREE, xarg2)),
  1161.        NULL_TREE, flags);
  1162.     /* This happens when the user mis-declares `operator delete'.
  1163.        Should now be impossible.  */
  1164.     my_friendly_assert (rval != error_mark_node, 250);
  1165.     TREE_TYPE (rval) = void_type_node;
  1166.     return rval;
  1167.       }
  1168.       break;
  1169.  
  1170.     default:
  1171.       binary_is_unary = 0;
  1172.       try_second = tree_code_length [(int) code] == 2;
  1173.       if (try_second && xarg2 == error_mark_node)
  1174.     return error_mark_node;
  1175.       break;
  1176.     }
  1177.  
  1178.   if (try_second && xarg2 == error_mark_node)
  1179.     return error_mark_node;
  1180.  
  1181.   /* What ever it was, we do not know how to deal with it.  */
  1182.   if (type1 == NULL_TREE)
  1183.     return rval;
  1184.  
  1185.   if (TREE_CODE (type1) == OFFSET_TYPE)
  1186.     type1 = TREE_TYPE (type1);
  1187.  
  1188.   if (TREE_CODE (type1) == REFERENCE_TYPE)
  1189.     {
  1190.       arg1 = convert_from_reference (xarg1);
  1191.       type1 = TREE_TYPE (arg1);
  1192.     }
  1193.   else
  1194.     {
  1195.       arg1 = xarg1;
  1196.     }
  1197.  
  1198.   if (!IS_AGGR_TYPE (type1) || TYPE_PTRMEMFUNC_P (type1))
  1199.     {
  1200.       /* Try to fail. First, fail if unary */
  1201.       if (! try_second)
  1202.     return rval;
  1203.       /* Second, see if second argument is non-aggregate. */
  1204.       type2 = TREE_TYPE (xarg2);
  1205.       if (TREE_CODE (type2) == OFFSET_TYPE)
  1206.     type2 = TREE_TYPE (type2);
  1207.       if (TREE_CODE (type2) == REFERENCE_TYPE)
  1208.     {
  1209.       arg2 = convert_from_reference (xarg2);
  1210.       type2 = TREE_TYPE (arg2);
  1211.     }
  1212.       else
  1213.     {
  1214.       arg2 = xarg2;
  1215.     }
  1216.  
  1217.       if (!IS_AGGR_TYPE (type2))
  1218.     return rval;
  1219.       try_second = 0;
  1220.     }
  1221.  
  1222.   if (try_second)
  1223.     {
  1224.       /* First arg may succeed; see whether second should.  */
  1225.       type2 = TREE_TYPE (xarg2);
  1226.       if (TREE_CODE (type2) == OFFSET_TYPE)
  1227.     type2 = TREE_TYPE (type2);
  1228.       if (TREE_CODE (type2) == REFERENCE_TYPE)
  1229.     {
  1230.       arg2 = convert_from_reference (xarg2);
  1231.       type2 = TREE_TYPE (arg2);
  1232.     }
  1233.       else
  1234.     {
  1235.       arg2 = xarg2;
  1236.     }
  1237.  
  1238.       if (! IS_AGGR_TYPE (type2))
  1239.     try_second = 0;
  1240.     }
  1241.  
  1242.   if (type1 == unknown_type_node
  1243.       || (try_second && TREE_TYPE (xarg2) == unknown_type_node))
  1244.     {
  1245.       /* This will not be implemented in the foreseeable future.  */
  1246.       return rval;
  1247.     }
  1248.  
  1249.   if (code == MODIFY_EXPR)
  1250.     fnname = ansi_assopname[(int) TREE_CODE (arg3)];
  1251.   else
  1252.     fnname = ansi_opname[(int) code];
  1253.  
  1254.   global_fn = lookup_name_nonclass (fnname);
  1255.  
  1256.   /* This is the last point where we will accept failure.  This
  1257.      may be too eager if we wish an overloaded operator not to match,
  1258.      but would rather a normal operator be called on a type-converted
  1259.      argument.  */
  1260.  
  1261.   if (IS_AGGR_TYPE (type1))
  1262.     {
  1263.       fields1 = lookup_fnfields (TYPE_BINFO (type1), fnname, 0);
  1264.       /* ARM $13.4.7, prefix/postfix ++/--.  */
  1265.       if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR)
  1266.     {
  1267.       xarg2 = integer_zero_node;
  1268.       binary_is_unary = 0;
  1269.  
  1270.       if (fields1)
  1271.         {
  1272.           tree t, t2;
  1273.           int have_postfix = 0;
  1274.  
  1275.           /* Look for an `operator++ (int)'.  If they didn't have
  1276.          one, then we fall back to the old way of doing things.  */
  1277.           for (t = TREE_VALUE (fields1); t ; t = TREE_CHAIN (t))
  1278.         {
  1279.           t2 = TYPE_ARG_TYPES (TREE_TYPE (t));
  1280.           if (TREE_CHAIN (t2) != NULL_TREE
  1281.               && TREE_VALUE (TREE_CHAIN (t2)) == integer_type_node)
  1282.             {
  1283.               have_postfix = 1;
  1284.               break;
  1285.             }
  1286.         }
  1287.  
  1288.           if (! have_postfix)
  1289.         {
  1290.           char *op = POSTINCREMENT_EXPR ? "++" : "--";
  1291.  
  1292.           /* There's probably a LOT of code in the world that
  1293.              relies upon this old behavior.  So we'll only give this
  1294.              warning when we've been given -pedantic.  A few
  1295.              releases after 2.4, we'll convert this to be a pedwarn
  1296.              or something else more appropriate.  */
  1297.           if (pedantic)
  1298.             warning ("no `operator%s (int)' declared for postfix `%s'",
  1299.                  op, op);
  1300.           xarg2 = NULL_TREE;
  1301.           binary_is_unary = 1;
  1302.         }
  1303.         }
  1304.     }
  1305.     }
  1306.  
  1307.   if (fields1 == NULL_TREE && global_fn == NULL_TREE)
  1308.     return rval;
  1309.  
  1310.   /* If RVAL winds up being `error_mark_node', we will return
  1311.      that... There is no way that normal semantics of these
  1312.      operators will succeed.  */
  1313.  
  1314.   /* This argument may be an uncommitted OFFSET_REF.  This is
  1315.      the case for example when dealing with static class members
  1316.      which are referenced from their class name rather than
  1317.      from a class instance.  */
  1318.   if (TREE_CODE (xarg1) == OFFSET_REF
  1319.       && TREE_CODE (TREE_OPERAND (xarg1, 1)) == VAR_DECL)
  1320.     xarg1 = TREE_OPERAND (xarg1, 1);
  1321.   if (try_second && xarg2 && TREE_CODE (xarg2) == OFFSET_REF
  1322.       && TREE_CODE (TREE_OPERAND (xarg2, 1)) == VAR_DECL)
  1323.     xarg2 = TREE_OPERAND (xarg2, 1);
  1324.  
  1325.   if (global_fn)
  1326.     flags |= LOOKUP_GLOBAL;
  1327.  
  1328.   if (code == CALL_EXPR)
  1329.     {
  1330.       /* This can only be a member function.  */
  1331.       return build_method_call (xarg1, fnname, xarg2,
  1332.                 NULL_TREE, LOOKUP_NORMAL);
  1333.     }
  1334.   else if (tree_code_length[(int) code] == 1 || binary_is_unary)
  1335.     {
  1336.       parms = NULL_TREE;
  1337.       rval = build_method_call (xarg1, fnname, NULL_TREE, NULL_TREE, flags);
  1338.     }
  1339.   else if (code == COND_EXPR)
  1340.     {
  1341.       parms = tree_cons (0, xarg2, build_tree_list (NULL_TREE, arg3));
  1342.       rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags);
  1343.     }
  1344.   else if (code == METHOD_CALL_EXPR)
  1345.     {
  1346.       /* must be a member function.  */
  1347.       parms = tree_cons (NULL_TREE, xarg2, arg3);
  1348.       return build_method_call (xarg1, fnname, parms, NULL_TREE,
  1349.                 LOOKUP_NORMAL);
  1350.     }
  1351.   else if (fields1)
  1352.     {
  1353.       parms = build_tree_list (NULL_TREE, xarg2);
  1354.       rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags);
  1355.     }
  1356.   else
  1357.     {
  1358.       parms = tree_cons (NULL_TREE, xarg1,
  1359.              build_tree_list (NULL_TREE, xarg2));
  1360.       rval = build_overload_call (fnname, parms, flags,
  1361.                   (struct candidate *)0);
  1362.     }
  1363.  
  1364.   return rval;
  1365. }
  1366.  
  1367. /* This function takes an identifier, ID, and attempts to figure out what
  1368.    it means. There are a number of possible scenarios, presented in increasing
  1369.    order of hair:
  1370.  
  1371.    1) not in a class's scope
  1372.    2) in class's scope, member name of the class's method
  1373.    3) in class's scope, but not a member name of the class
  1374.    4) in class's scope, member name of a class's variable
  1375.  
  1376.    NAME is $1 from the bison rule. It is an IDENTIFIER_NODE.
  1377.    VALUE is $$ from the bison rule. It is the value returned by lookup_name ($1)
  1378.    yychar is the pending input character (suitably encoded :-).
  1379.  
  1380.    As a last ditch, try to look up the name as a label and return that
  1381.    address.
  1382.  
  1383.    Values which are declared as being of REFERENCE_TYPE are
  1384.    automatically dereferenced here (as a hack to make the
  1385.    compiler faster).  */
  1386.  
  1387. tree
  1388. hack_identifier (value, name, yychar)
  1389.      tree value, name;
  1390.      int yychar;
  1391. {
  1392.   tree type;
  1393.  
  1394.   if (TREE_CODE (value) == ERROR_MARK)
  1395.     {
  1396.       if (current_class_name)
  1397.     {
  1398.       tree fields = lookup_fnfields (TYPE_BINFO (current_class_type), name, 1);
  1399.       if (fields == error_mark_node)
  1400.         return error_mark_node;
  1401.       if (fields)
  1402.         {
  1403.           tree fndecl;
  1404.  
  1405.           fndecl = TREE_VALUE (fields);
  1406.           my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 251);
  1407.           if (DECL_CHAIN (fndecl) == NULL_TREE)
  1408.         {
  1409.           warning ("methods cannot be converted to function pointers");
  1410.           return fndecl;
  1411.         }
  1412.           else
  1413.         {
  1414.           error ("ambiguous request for method pointer `%s'",
  1415.              IDENTIFIER_POINTER (name));
  1416.           return error_mark_node;
  1417.         }
  1418.         }
  1419.     }
  1420.       if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name))
  1421.     {
  1422.       return IDENTIFIER_LABEL_VALUE (name);
  1423.     }
  1424.       return error_mark_node;
  1425.     }
  1426.  
  1427.   type = TREE_TYPE (value);
  1428.   if (TREE_CODE (value) == FIELD_DECL)
  1429.     {
  1430.       if (current_class_decl == NULL_TREE)
  1431.     {
  1432.       error ("request for member `%s' in static member function",
  1433.          IDENTIFIER_POINTER (DECL_NAME (value)));
  1434.       return error_mark_node;
  1435.     }
  1436.       TREE_USED (current_class_decl) = 1;
  1437.       if (yychar == '(')
  1438.     if (! ((TYPE_LANG_SPECIFIC (type)
  1439.         && TYPE_OVERLOADS_CALL_EXPR (type))
  1440.            || (TREE_CODE (type) == REFERENCE_TYPE
  1441.            && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
  1442.            && TYPE_OVERLOADS_CALL_EXPR (TREE_TYPE (type))))
  1443.         && TREE_CODE (type) != FUNCTION_TYPE
  1444.         && TREE_CODE (type) != METHOD_TYPE
  1445.         && !TYPE_PTRMEMFUNC_P (type)
  1446.         && (TREE_CODE (type) != POINTER_TYPE
  1447.         || (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
  1448.             && TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)))
  1449.       {
  1450.         error ("component `%s' is not a method",
  1451.            IDENTIFIER_POINTER (name));
  1452.         return error_mark_node;
  1453.       }
  1454.       /* Mark so that if we are in a constructor, and then find that
  1455.      this field was initialized by a base initializer,
  1456.      we can emit an error message.  */
  1457.       TREE_USED (value) = 1;
  1458.       return build_component_ref (C_C_D, name, 0, 1);
  1459.     }
  1460.  
  1461.   if (really_overloaded_fn (value))
  1462.     {
  1463.       tree t = get_first_fn (value);
  1464.       while (t)
  1465.     {
  1466.       assemble_external (t);
  1467.       TREE_USED (t) = 1;
  1468.       t = DECL_CHAIN (t);
  1469.     }
  1470.     }
  1471.   else if (TREE_CODE (value) == TREE_LIST)
  1472.     {
  1473.       tree t = value;
  1474.       while (t && TREE_CODE (t) == TREE_LIST)
  1475.     {
  1476.       assemble_external (TREE_VALUE (t));
  1477.       TREE_USED (t) = 1;
  1478.       t = TREE_CHAIN (t);
  1479.     }
  1480.     }
  1481.   else
  1482.     {
  1483.       assemble_external (value);
  1484.       TREE_USED (value) = 1;
  1485.     }
  1486.  
  1487.   if (TREE_CODE_CLASS (TREE_CODE (value)) == 'd' && DECL_NONLOCAL (value))
  1488.     {
  1489.       if (DECL_LANG_SPECIFIC (value)
  1490.       && DECL_CLASS_CONTEXT (value) != current_class_type)
  1491.     {
  1492.       tree path;
  1493.       enum access_type access;
  1494.       register tree context
  1495.         = (TREE_CODE (value) == FUNCTION_DECL && DECL_VIRTUAL_P (value))
  1496.           ? DECL_CLASS_CONTEXT (value)
  1497.           : DECL_CONTEXT (value);
  1498.  
  1499.       get_base_distance (context, current_class_type, 0, &path);
  1500.       if (path)
  1501.         {
  1502.           access = compute_access (path, value);
  1503.           if (access != access_public)
  1504.         {
  1505.           if (TREE_CODE (value) == VAR_DECL)
  1506.             error ("static member `%s' is %s",
  1507.                IDENTIFIER_POINTER (name),
  1508.                TREE_PRIVATE (value) ? "private" :
  1509.                "from a private base class");
  1510.           else
  1511.             error ("enum `%s' is from private base class",
  1512.                IDENTIFIER_POINTER (name));
  1513.           return error_mark_node;
  1514.         }
  1515.         }
  1516.     }
  1517.       return value;
  1518.     }
  1519.   if (TREE_CODE (value) == TREE_LIST && TREE_NONLOCAL_FLAG (value))
  1520.     {
  1521.       if (type == 0)
  1522.     {
  1523.       error ("request for member `%s' is ambiguous in multiple inheritance lattice",
  1524.          IDENTIFIER_POINTER (name));
  1525.       return error_mark_node;
  1526.     }
  1527.  
  1528.       return value;
  1529.     }
  1530.  
  1531.   if (TREE_CODE (type) == REFERENCE_TYPE)
  1532.     {
  1533.       my_friendly_assert (TREE_CODE (value) == VAR_DECL
  1534.               || TREE_CODE (value) == PARM_DECL
  1535.               || TREE_CODE (value) == RESULT_DECL, 252);
  1536.       if (DECL_REFERENCE_SLOT (value))
  1537.     return DECL_REFERENCE_SLOT (value);
  1538.     }
  1539.   return value;
  1540. }
  1541.  
  1542.  
  1543. #if 0
  1544. /* Given an object OF, and a type conversion operator COMPONENT
  1545.    build a call to the conversion operator, if a call is requested,
  1546.    or return the address (as a pointer to member function) if one is not.
  1547.  
  1548.    OF can be a TYPE_DECL or any kind of datum that would normally
  1549.    be passed to `build_component_ref'.  It may also be NULL_TREE,
  1550.    in which case `current_class_type' and `current_class_decl'
  1551.    provide default values.
  1552.  
  1553.    BASETYPE_PATH, if non-null, is the path of basetypes
  1554.    to go through before we get the the instance of interest.
  1555.  
  1556.    PROTECT says whether we apply C++ scoping rules or not.  */
  1557. tree
  1558. build_component_type_expr (of, component, basetype_path, protect)
  1559.      tree of, component, basetype_path;
  1560.      int protect;
  1561. {
  1562.   tree cname = NULL_TREE;
  1563.   tree tmp, last;
  1564.   tree name;
  1565.   int flags = protect ? LOOKUP_NORMAL : LOOKUP_COMPLAIN;
  1566.  
  1567.   if (of)
  1568.     my_friendly_assert (IS_AGGR_TYPE (TREE_TYPE (of)), 253);
  1569.   my_friendly_assert (TREE_CODE (component) == TYPE_EXPR, 254);
  1570.  
  1571.   tmp = TREE_OPERAND (component, 0);
  1572.   last = NULL_TREE;
  1573.  
  1574.   while (tmp)
  1575.     {
  1576.       switch (TREE_CODE (tmp))
  1577.     {
  1578.     case CALL_EXPR:
  1579.       if (last)
  1580.         TREE_OPERAND (last, 0) = TREE_OPERAND (tmp, 0);
  1581.       else
  1582.         TREE_OPERAND (component, 0) = TREE_OPERAND (tmp, 0);
  1583.  
  1584.       last = groktypename (build_tree_list (TREE_TYPE (component),
  1585.                         TREE_OPERAND (component, 0)));
  1586.       name = build_typename_overload (last);
  1587.       TREE_TYPE (name) = last;
  1588.  
  1589.       if (TREE_OPERAND (tmp, 0)
  1590.           && TREE_OPERAND (tmp, 0) != void_list_node)
  1591.         {
  1592.           cp_error ("`operator %T' requires empty parameter list", last);
  1593.           TREE_OPERAND (tmp, 0) = NULL_TREE;
  1594.         }
  1595.  
  1596.       if (of && TREE_CODE (of) != TYPE_DECL)
  1597.         return build_method_call (of, name, NULL_TREE, NULL_TREE, flags);
  1598.       else if (of)
  1599.         {
  1600.           tree this_this;
  1601.  
  1602.           if (current_class_decl == NULL_TREE)
  1603.         {
  1604.           cp_error ("object required for `operator %T' call",
  1605.                 TREE_TYPE (name));
  1606.           return error_mark_node;
  1607.         }
  1608.  
  1609.           this_this = convert_pointer_to (TREE_TYPE (of),
  1610.                           current_class_decl);
  1611.           this_this = build_indirect_ref (this_this, NULL_PTR);
  1612.           return build_method_call (this_this, name, NULL_TREE,
  1613.                     NULL_TREE, flags | LOOKUP_NONVIRTUAL);
  1614.         }
  1615.       else if (current_class_decl)
  1616.         return build_method_call (tmp, name, NULL_TREE, NULL_TREE, flags);
  1617.  
  1618.       cp_error ("object required for `operator %T' call",
  1619.             TREE_TYPE (name));
  1620.       return error_mark_node;
  1621.  
  1622.     case INDIRECT_REF:
  1623.     case ADDR_EXPR:
  1624.     case ARRAY_REF:
  1625.       break;
  1626.  
  1627.     case SCOPE_REF:
  1628.       my_friendly_assert (cname == 0, 255);
  1629.       cname = TREE_OPERAND (tmp, 0);
  1630.       tmp = TREE_OPERAND (tmp, 1);
  1631.       break;
  1632.  
  1633.     default:
  1634.       my_friendly_abort (77);
  1635.     }
  1636.       last = tmp;
  1637.       tmp = TREE_OPERAND (tmp, 0);
  1638.     }
  1639.  
  1640.   last = groktypename (build_tree_list (TREE_TYPE (component), TREE_OPERAND (component, 0)));
  1641.   name = build_typename_overload (last);
  1642.   TREE_TYPE (name) = last;
  1643.   if (of && TREE_CODE (of) == TYPE_DECL)
  1644.     {
  1645.       if (cname == NULL_TREE)
  1646.     {
  1647.       cname = DECL_NAME (of);
  1648.       of = NULL_TREE;
  1649.     }
  1650.       else my_friendly_assert (cname == DECL_NAME (of), 256);
  1651.     }
  1652.  
  1653.   if (of)
  1654.     {
  1655.       tree this_this;
  1656.  
  1657.       if (current_class_decl == NULL_TREE)
  1658.     {
  1659.       cp_error ("object required for `operator %T' call",
  1660.             TREE_TYPE (name));
  1661.       return error_mark_node;
  1662.     }
  1663.  
  1664.       this_this = convert_pointer_to (TREE_TYPE (of), current_class_decl);
  1665.       return build_component_ref (this_this, name, 0, protect);
  1666.     }
  1667.   else if (cname)
  1668.     return build_offset_ref (cname, name);
  1669.   else if (current_class_name)
  1670.     return build_offset_ref (current_class_name, name);
  1671.  
  1672.   cp_error ("object required for `operator %T' member reference",
  1673.         TREE_TYPE (name));
  1674.   return error_mark_node;
  1675. }
  1676. #endif
  1677.  
  1678. static char *
  1679. thunk_printable_name (decl)
  1680.      tree decl;
  1681. {
  1682.   return "<thunk function>";
  1683. }
  1684.  
  1685. tree
  1686. make_thunk (function, delta)
  1687.      tree function;
  1688.      int delta;
  1689. {
  1690.   char buffer[250];
  1691.   tree thunk_fndecl, thunk_id;
  1692.   tree thunk;
  1693.   char *func_name;
  1694.   static int thunk_number = 0;
  1695.   tree func_decl;
  1696.   if (TREE_CODE (function) != ADDR_EXPR)
  1697.     abort ();
  1698.   func_decl = TREE_OPERAND (function, 0);
  1699.   if (TREE_CODE (func_decl) != FUNCTION_DECL)
  1700.     abort ();
  1701.   func_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func_decl));
  1702.   sprintf (buffer, "__thunk_%d_%s", -delta, func_name);
  1703.   thunk_id = get_identifier (buffer);
  1704.   thunk = IDENTIFIER_GLOBAL_VALUE (thunk_id);
  1705.   if (thunk && TREE_CODE (thunk) != THUNK_DECL)
  1706.     {
  1707.       error_with_decl ("implementation-reserved name `%s' used");
  1708.       IDENTIFIER_GLOBAL_VALUE (thunk_id) = thunk = NULL_TREE;
  1709.     }
  1710.   if (thunk == NULL_TREE)
  1711.     {
  1712.       thunk = build_decl (THUNK_DECL, thunk_id, TREE_TYPE (func_decl));
  1713.       DECL_RESULT (thunk)
  1714.     = build_decl (RESULT_DECL, NULL_TREE, TREE_TYPE (vtable_entry_type));
  1715.       make_function_rtl (thunk);
  1716.       DECL_INITIAL (thunk) = function;
  1717.       THUNK_DELTA (thunk) = delta;
  1718.       /* So that finish_file can write out any thunks that need to be: */
  1719.       pushdecl_top_level (thunk);
  1720.     }
  1721.   return thunk;
  1722. }
  1723.  
  1724. void
  1725. emit_thunk (thunk_fndecl)
  1726.   tree thunk_fndecl;
  1727. {
  1728.   rtx insns;
  1729.   char *fnname;
  1730.   char buffer[250];
  1731.   tree argp;
  1732.   struct args_size stack_args_size;
  1733.   tree function = TREE_OPERAND (DECL_INITIAL (thunk_fndecl), 0);
  1734.   int delta = THUNK_DELTA (thunk_fndecl);
  1735.   int tem;
  1736.   int failure = 0;
  1737.   int current_call_is_indirect = 0;    /* needed for HPPA FUNCTION_ARG */
  1738.  
  1739.   /* Used to remember which regs we need to emit a USE rtx for. */
  1740.   rtx need_use[FIRST_PSEUDO_REGISTER];
  1741.   int need_use_count = 0;
  1742.  
  1743.   /* rtx for the 'this' parameter. */
  1744.   rtx this_rtx = 0, this_reg_rtx = 0, fixed_this_rtx;
  1745.  
  1746.   char *(*save_decl_printable_name) () = decl_printable_name;
  1747.   /* Data on reg parms scanned so far.  */
  1748.   CUMULATIVE_ARGS args_so_far;
  1749.  
  1750.   if (TREE_ASM_WRITTEN (thunk_fndecl))
  1751.     return;
  1752.  
  1753.   TREE_ASM_WRITTEN (thunk_fndecl) = 1;
  1754.  
  1755.   if (TREE_PUBLIC (function))
  1756.     {
  1757.       TREE_PUBLIC (thunk_fndecl) = 1;
  1758.       if (DECL_EXTERNAL (function))
  1759.     {
  1760.       DECL_EXTERNAL (thunk_fndecl) = 1;
  1761.       assemble_external (thunk_fndecl);
  1762.       return;
  1763.     }
  1764.     }
  1765.  
  1766.   decl_printable_name = thunk_printable_name;
  1767.   if (current_function_decl)
  1768.     abort ();
  1769.   current_function_decl = thunk_fndecl;
  1770.   init_function_start (thunk_fndecl, input_filename, lineno);
  1771.   pushlevel (0);
  1772.   expand_start_bindings (1);
  1773.  
  1774.   /* Start updating where the next arg would go.  */
  1775.   INIT_CUMULATIVE_ARGS (args_so_far, TREE_TYPE (function), NULL_RTX);
  1776.   stack_args_size.constant = 0;
  1777.   stack_args_size.var = 0;
  1778.   /* SETUP for possible structure return address FIXME */
  1779.  
  1780.   /* Now look through all the parameters, make sure that we
  1781.      don't clobber any registers used for parameters.
  1782.      Also, pick up an rtx for the first "this" parameter. */
  1783.   for (argp = TYPE_ARG_TYPES (TREE_TYPE (function));
  1784.        argp != NULL_TREE;
  1785.        argp = TREE_CHAIN (argp))
  1786.  
  1787.     {
  1788.       tree passed_type = TREE_VALUE (argp);
  1789.       register rtx entry_parm;
  1790.       int named = 1; /* FIXME */
  1791.       struct args_size stack_offset;
  1792.       struct args_size arg_size;
  1793.  
  1794.       if (passed_type == void_type_node)
  1795.     break;
  1796.  
  1797.       if ((TREE_CODE (TYPE_SIZE (passed_type)) != INTEGER_CST
  1798.        && contains_placeholder_p (TYPE_SIZE (passed_type)))
  1799. #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
  1800.       || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far,
  1801.                          TYPE_MODE (passed_type),
  1802.                          passed_type, named)
  1803. #endif
  1804.       )
  1805.     passed_type = build_pointer_type (passed_type);
  1806.  
  1807.       entry_parm = FUNCTION_ARG (args_so_far,
  1808.                  TYPE_MODE (passed_type),
  1809.                  passed_type,
  1810.                  named);
  1811.       if (entry_parm != 0)
  1812.     need_use[need_use_count++] = entry_parm;
  1813.  
  1814.       locate_and_pad_parm (TYPE_MODE (passed_type), passed_type,
  1815. #ifdef STACK_PARMS_IN_REG_PARM_AREA
  1816.                1,
  1817. #else
  1818.                entry_parm != 0,
  1819. #endif
  1820.                thunk_fndecl,
  1821.                &stack_args_size, &stack_offset, &arg_size);
  1822.  
  1823. /*    REGNO (entry_parm);*/
  1824.       if (this_rtx == 0)
  1825.     {
  1826.       this_reg_rtx = entry_parm;
  1827.       if (!entry_parm)
  1828.         {
  1829.           rtx offset_rtx = ARGS_SIZE_RTX (stack_offset);
  1830.  
  1831.           rtx internal_arg_pointer, stack_parm;
  1832.  
  1833.           if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM
  1834.            || ! (fixed_regs[ARG_POINTER_REGNUM]
  1835.              || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM)))
  1836.         internal_arg_pointer = copy_to_reg (virtual_incoming_args_rtx);
  1837.           else
  1838.         internal_arg_pointer = virtual_incoming_args_rtx;
  1839.  
  1840.           if (offset_rtx == const0_rtx)
  1841.         entry_parm = gen_rtx (MEM, TYPE_MODE (passed_type),
  1842.                       internal_arg_pointer);
  1843.           else
  1844.         entry_parm = gen_rtx (MEM, TYPE_MODE (passed_type),
  1845.                       gen_rtx (PLUS, Pmode,
  1846.                            internal_arg_pointer, 
  1847.                            offset_rtx));
  1848.         }
  1849.       
  1850.       this_rtx = entry_parm;
  1851.     }
  1852.  
  1853.       FUNCTION_ARG_ADVANCE (args_so_far,
  1854.                 TYPE_MODE (passed_type),
  1855.                 passed_type,
  1856.                 named);
  1857.     }
  1858.  
  1859.   fixed_this_rtx = plus_constant (this_rtx, delta);
  1860.   if (this_rtx != fixed_this_rtx)
  1861.     emit_move_insn (this_rtx, fixed_this_rtx);
  1862.  
  1863.   if (this_reg_rtx)
  1864.     emit_insn (gen_rtx (USE, VOIDmode, this_reg_rtx));
  1865.  
  1866.   emit_indirect_jump (XEXP (DECL_RTL (function), 0));
  1867.  
  1868.   while (need_use_count > 0)
  1869.     emit_insn (gen_rtx (USE, VOIDmode, need_use[--need_use_count]));
  1870.  
  1871.   expand_end_bindings (NULL, 1, 0);
  1872.   poplevel (0, 0, 0);
  1873.  
  1874.   /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
  1875.      Note that that may have been done above, in save_for_inline_copying.
  1876.      The call to resume_temporary_allocation near the end of this function
  1877.      goes back to the usual state of affairs.  */
  1878.  
  1879.   rtl_in_current_obstack ();
  1880.  
  1881.   insns = get_insns ();
  1882.  
  1883.   /* Copy any shared structure that should not be shared.  */
  1884.  
  1885.   unshare_all_rtl (insns);
  1886.  
  1887.   /* We are no longer anticipating cse in this function, at least.  */
  1888.  
  1889.   cse_not_expected = 1;
  1890.  
  1891.   /* Now we choose between stupid (pcc-like) register allocation
  1892.      (if we got the -noreg switch and not -opt)
  1893.      and smart register allocation.  */
  1894.  
  1895.   if (optimize > 0)            /* Stupid allocation probably won't work */
  1896.     obey_regdecls = 0;        /* if optimizations being done.  */
  1897.  
  1898.   regclass_init ();
  1899.  
  1900.   regclass (insns, max_reg_num ());
  1901.   if (obey_regdecls)
  1902.     {
  1903.       stupid_life_analysis (insns, max_reg_num (), NULL);
  1904.       failure = reload (insns, 0, NULL);
  1905.     }
  1906.   else
  1907.     {
  1908.       /* Do control and data flow analysis,
  1909.      and write some of the results to dump file.  */
  1910.  
  1911.       flow_analysis (insns, max_reg_num (), NULL);
  1912.       local_alloc ();
  1913.       failure = global_alloc (NULL);
  1914.     }
  1915.  
  1916.   reload_completed = 1;
  1917.  
  1918. #ifdef LEAF_REGISTERS
  1919.   leaf_function = 0;
  1920.   if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
  1921.     leaf_function = 1;
  1922. #endif
  1923.  
  1924.   /* If a machine dependent reorganization is needed, call it.  */
  1925. #ifdef MACHINE_DEPENDENT_REORG
  1926.    MACHINE_DEPENDENT_REORG (insns);
  1927. #endif
  1928.  
  1929.   /* Now turn the rtl into assembler code.  */
  1930.  
  1931.     {
  1932.       char *fnname = XSTR (XEXP (DECL_RTL (thunk_fndecl), 0), 0);
  1933.       assemble_start_function (thunk_fndecl, fnname);
  1934.       final (insns, asm_out_file, optimize, 0);
  1935.       assemble_end_function (thunk_fndecl, fnname);
  1936.     };
  1937.  
  1938.  exit_rest_of_compilation:
  1939.  
  1940.   reload_completed = 0;
  1941.  
  1942.   /* Cancel the effect of rtl_in_current_obstack.  */
  1943.  
  1944.   resume_temporary_allocation ();
  1945.  
  1946.   decl_printable_name = save_decl_printable_name;
  1947.   current_function_decl = 0;
  1948. }
  1949.